import java.awt.Image;

import javax.swing.ImageIcon;

/**
 * Contains value and suit of all 52 cards
 */
//new edit
public class Card implements Comparable<Card>
{
    String[] su = {"Spades","Hearts","Clubs","Diamonds"};
    String[] va = {"2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace"};
    String[] val = {"Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King","Ace"};
    int value;
    int suit;
    
    public Card(int v, int s)
    {
        value = v;
        suit = s;
    }
    
    public String toString()
    {
        return va[value]+"_of_"+su[suit];
    }
    
    public int getValue()
    {
        return value;
    }
    
    public int getSuit()
    {
        return suit;
    }
    
    public String getCard()
    {
        return value+" "+suit;
    }
    public Image getCardImage()
    {
        ImageIcon img = null;
        Image imgg = null;
        /*
        try{
            Toolkit tk = Toolkit.getDefaultToolkit();
	    img = tk.getImage("resources\\"+val[value]+"_of_"+su[suit]+".png");
        } catch(Exception e){
            System.out.println("Error File Not Found in Card in method getCardImage()");
        }*/
        try{
        	img = new ImageIcon(getClass().getResource("resources/"+val[value]+"_of_"+su[suit]+".png"));
        }catch(Exception e){}
        imgg = img.getImage();
        return imgg;
    }
    public Image getBackOfCard()
    {
        ImageIcon img = null;
        Image imgg = null;
        /*
        try{
            Toolkit tk = Toolkit.getDefaultToolkit();
	    img = tk.getImage("resources\\"+val[value]+"_of_"+su[suit]+".png");
        } catch(Exception e){
            System.out.println("Error File Not Found in Card in method getCardImage()");
        }*/
        try{
        	img = new ImageIcon(getClass().getResource("resources/Back_of_Card.png"));
        }catch(Exception e){}
        imgg = img.getImage();
        return imgg;
    }
    public ImageIcon getImageIcon()
    {
        ImageIcon icon = new ImageIcon(getCardImage());
        return icon;
    }
    /*
     * abstract method for Comaparable<Card>
     */
    public int compareTo(Card card)
    {
    	if(getSuit() != card.getSuit())
    		return getSuit() - card.getSuit();
    	return card.getValue() - getValue();
    }

}
